/*
 * trjInput.cpp
 *
 *  Created on: May 22, 2012
 *      Author: marchi
 */

#include "trjInput.h"

namespace trj {
trjInput::trjInput(int ntot,char ** v) {
	vector<string> in;

	inmap["-o"]=in;
	inmap["-dcd"]=in;
	inmap["-xtc"]=in;
	inmap["-rcm"]=in;
	inmap["-b"]=in;
	inmap["-e"]=in;
	inmap["-skip"]=in;
	inmap["-pdb"]=in;
	inmap["-nohyd"]=in;
	inmap["-hyd"]=in;
	inmap["-nodel"]=in;
	inmap["-del"]=in;
	inmap["-center"]=in;
	inmap["-select"]=in;
	inmap["-prof"]=in;
	inmap["-pVct"]=in;
	inmap["-pdx1"]=in;
	inmap["-pdx2"]=in;
	inmap["-cut"]=in;
	inmap["-rcut"]=in;
	inmap["-cutX"]=in;
	inmap["-grid"]=in;
	inmap["-chg"]=in;
	inmap["-help"]=in;
	inmap["-irl"]=in;
	inmap["-irdb"]=in;
	inmap["-rd"]=in;
	inmap["-clust"]=in;
	inmap["-once"]=in;


	map<string,vector<string> >::iterator it=inmap.begin();
	for(int n=0;it!=inmap.end();++it,n++){
		Usage[n]=" ";
	}
	Usage[0]="\t -dcd file.dcd \n";
	Usage[1]="\t -xtc file.xtc\n";
	Usage[2]="\t -pdb file.pdb \n";
	Usage[3]="\t -o fileout // For fileout extensions .xtc and .pdb, a .xtc or .pdb file is written to output.\n"
			"\t\tA fileout with extension .prf automatically set the option -prof. \n"
			"\t\tA fileout with extention .dip will cause the program to compute the dipole moment of the selection.\n";
	Usage[4]="\t -b No. First Frame \n";
	Usage[5]="\t -e No. Last Frame\n";
	Usage[6]="\t -skip No. of frames to be skipped [not implemented]\n";
	Usage[7]="\t -nohyd // Do not include hydrogens in Mycelle calculation [default] \n";
	Usage[8]="\t -hyd // Include hydrogens in the Micelle calculation \n";
	Usage[9]="\t -nodel // Do not delete temporary files in MPI runs \n";
	Usage[10]="\t -del // Delete temporary files in MPI runs [default]\n";
	Usage[11]="\t -center // Reference residue. Used to reconstruct the micelle. This is a required parameter. \n";
	Usage[12]="\t -select // List of residues forming the micelle. This is a required parameter. \n";
	Usage[13]="\t -prof // Compute the radial and 2D density profiles.\n";
	Usage[14]="\t -cut cutoff // General cutoff. For the radial profile cutoff is the spherical cuoff.\n"
			"\t\tFor the 2D profile cutoff is the on plane cutoff. Default value is 40 A\n";
	Usage[15]="\t -cutX cutoff // Out of plane cutoff for 2D profiling. Default value is 5 A.\n";
	Usage[16]="\t -pVct (string) Axes// Axes can take values as \"X\", \"Y\" or \"Z\". \n  "
			"\t\tThis is the axis perpendicular to the plane to be profiled to output. Default is \"X\".\n";
	Usage[17]="\t  -pdx1 dx1 // Bin size of the radial histograms.\n";
	Usage[18]="\t  -pdx2 dx2 // Bin size of the 2D histograms.\n";
	Usage[19]="\t  -chg filename // Input charges for the selected residues.\n";
	Usage[20]="\t  -grid nx ny nz // Number of grid points in the three directione. Default nx=ny=nz=128.\n";
	Usage[21]="\t -irl   // Input radius list to be used with the -w option. Default values:\n"
			"\t\t Tsai et al., J Mol Biol 290:253 (1999) \n";
	Usage[22]="\t -idb   // Input residue database for radius to be used with the -w option \n";
	Usage[23]="\t -rd // Use atomic radii in the Micelle calculation \n";
	Usage[24]="\t -clust // Compute cluster size of detergent heads and ions \n";
	Usage[25]="\t -rcut cutoff // Cutoff for Linked Lists. Default value is 18.0 A.\n";
	Usage[26]="\t -once // Compute cluster size of detergent heads and ions only once! \n";
	Usage[27]="\t -rcm file.rcm\n";
	Usage[28]="\t -help // write some on line help \n";

	int n=1;
	string key;
	for(;n<ntot;){
		string tmp0(v[n]);
		if(v[n][0] =='-'){
			key.assign(v[n]);
			if(inmap.find(key) != inmap.end()){
				if(inmap[key].empty()) inmap[key].push_back(tmp0);
			} else{
				unknownC.push_back(key);
				inmap[key].push_back(tmp0);
			}
		}
		else{
			inmap[key].push_back(tmp0);
		}
		n++;
	}

}

vector<string> trjInput::getUsage(){
	vector<string> use;
	map<int,string>::iterator it=Usage.begin();
	for(;it!=Usage.end();++it){
		use.push_back(it->second);
	}
	return use;
}
trjInput::~trjInput() {
	// TODO Auto-generated destructor stub
}

} /* namespace trj */
